/*
 * Website.cpp
 *
 *  Created on: Apr 13, 2011
 *      Author: nathanielclinger
 */
#include <iostream>
#include <string>
#include <sstream>
#include <map>
#include "URL.hpp"
#include "ArrayList.hpp"
#include "GetPostParser.h"
//#include "Comment.hpp"


void header()
{
	cout << "<html><head><title>Title</title><link href=\"./style.css\" type= \"text/css\" rel=\"stylesheet\" />" ;

	// a bit of java script for the menu
	cout << "<script type=\"text/javascript\">"
			<< "function toggleurl() {"
				<< "var ele = document.getElementById(\"toggleurl\");"
				<< "var text = document.getElementById(\"displayurl\");"
				<< "if(ele.style.display == \"block\") {"
	    			<< "ele.style.display = \"none\";"
	    			<< "text.innerHTML = \"Post a new URL\";"
	  			<< "}"
	  			<< "else {"
	  				<< "ele.style.display = \"block\";"
	  				<< "text.innerHTML = \"Post a new URL\";"
				<< "}"
			<< "}"
			<< "</script>" ;


	cout << "</head><body>" ;

	// menu
	cout << "<div class=\"header\"><h1 class=\"sitetitle\"><a href=\"/\">URLScreener</a></h1></div><!--header-->" << endl
			<<	"<div class=\"menu\"><ul><li><a href=\"/\" >Home</a></li>" << endl
			<< "<li><a id=\"displayurl\" href=\"javascript:toggleurl();\">Post a new URL</a></li>" << endl
			<< "<li><a href=\"#\" >Sort By</a><ul>" << endl
			<< "<li><a href=\"#\">See all URLs</a></li>" << endl
			<< "<li><a href=\"#\">See all URLs</a></li>" << endl
			<< "<li><a href=\"#\">See all URLs</a></li>" << endl
			<< "</ul></li><li><a href=\"/ownstats\" >Stats</a></li></ul></div><!--menu-->" << endl ;

	cout << "<div id=\"toggleurl\" style=\"display:none;\"><div class=\"contentboxurl\">" << endl
			<< "<h3>Enter the URL</h3><form action=\"#\" method=\"get\"><input type=\"text\" name=\"url\" size=\"160\"/><br />" << endl
			<< "<h3>Enter a Category Name</h3><input type=\"text\" name=\"url\" size=\"160\"/><br />" << endl
			<< "<input type=\"submit\" value=\"Submit\" /></form></div><!--contentbox URL--></div><!--toggle-->" << endl ;
}

void footer()
{
	cout << "<div class=\"footer\">Created by Nathaniel Clinger</div></body></html>" ;
}

int main()
{
	ArrayList<URL> urls ;
	map<string,string> get ;
	initializeGet( get ) ;

	URL a( "www.asdf.com" ) ;

	cout << "Content-type: text/html" << endl << endl ;

	if( get.empty() )
		cout << "is empty" ;
	else
		cout << "is not empty: " < get.size() ;
	header() ;

	// print URL
	cout << a ;

	footer() ;

	return 0 ;
}
